(define test 25)

(display "ex1-11:\n")
;递归计算过程
(define (f n)
    (if (< n 3)
        n
        (+ (f (- n 1)) (* 2 (f (- n 2))) (* 3 (f (- n 3))))))

(display (f test))
(newline)

;迭代计算过程
(define (f1 n)
    (define (f-iter fn fn-1 fn-2 fn-3 count n)
        (if (>= count n)
            fn
            (f-iter (+ fn (* 2 fn-1) (* 3 fn-2)) fn fn-1 fn-2 (+ count 1) n)))
    (if (< n 3)
        n
        (f-iter 4 2 1 0 3 n)))

(display (f1 test))